package ygFlower.dao;

import org.springframework.orm.jpa.support.JpaDaoSupport;
import ygFlower.domain.Flower;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: lee
 * Date: 2010-1-26
 * Time: 21:33:59
 * To change this template use File | Settings | File Templates.
 */
public class JpaFlowerDao extends JpaDaoSupport{
    public List<Flower> queryAll(){
        return getJpaTemplate().find("select b from Flower b");
    }
    public void create(Flower flower){
        getJpaTemplate().persist(flower);
    }
    public void delete(String id){
        Flower flower = queryById(id);
        getJpaTemplate().remove(flower);
    }
    public void update(Flower flower ){
        getJpaTemplate().merge(flower);
    }
    public Flower queryById(String id){
        return getJpaTemplate().find(Flower.class,id);
    }
}
